Resize subroutine
'
'
' ***** Resize *****
'
SUB Resize
  vv2 = v2
  vv3 = v3
  GOSUB GetSmallestSize     ' returns bw and heights
  v2 = MAX (vv2, v2)
  v3 = MAX (vv3, v3)
'
  XuiPositionGrid (grid, @v0, @v1, @v2, @v3)
'
  h = labelHeight + buttonHeight + textHeight + bw + bw
  IF (v3 >= h + 4) THEN
    buttonHeight = buttonHeight + 4 : h = h + 4
    IF (v3 >= h + 4) THEN textHeight = textHeight + 4
  END IF
'
  labelWidth = v2 - bw - bw
  labelHeight = v3 - buttonHeight - textHeight - bw - bw
  buttonWidth = labelWidth >> 1
  w0 = buttonWidth
  w1 = labelWidth - w0
'
  x = v0 + bw
  y = v1 + bw
  w = labelWidth
  XuiSendMessage (grid, #Resize, x, y, w, labelHeight, $Label, 0)
'
  y = y + labelHeight
  XuiSendMessage (grid, #Resize, x, y, w, textHeight, $TextLine, 0)
'
  h = buttonHeight
  y = y + textHeight
  XuiSendMessage (grid, #Resize, x, y, w0, h, $Button0, 0) : x = x + w0
  XuiSendMessage (grid, #Resize, x, y, w1, h, $Button1, 0) : x = x + w1
  XuiResizeWindowToGrid (grid, #ResizeWindowToGrid, v0, v1, v2, v3, 0, 0)
END SUB

The Resize subroutine is supposed to change the x,y,width,height position and size of the XuiDialog2B grid to v0,v1,v2,v3 .

Resize first it calls its own GetSmallestSize subroutine to see if the requested width,height is smaller than the grid can resize. XuiPositionGrid() sets the position and size of the XuiDialog2B grid in window coordinates.

Taking advantage of several variables that GetSmallestSize already computed, the Resize subroutine computes the width and height of all the kid grids, and sends a #Resize message to each kid to set its position and size.

Finally, Resize calls ResizeWindowToGrid() function, which resizes the window to the XuiDialog2B grid if the XuiDialog2B grid was created by a CreateWindow message.  In other words, ResizeWindowToGrid() resizes the window only if the grid is supposed to fill the grid.